import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.LinkedList;


public class DrawFactory {

	protected LinkedList<Draw> draws;
	
	public static void main(String[] args)
	{
		DrawFactory factory = new DrawFactory();
		factory.createDraws();
		System.out.println(factory.createFileString(GregorianCalendar.TUESDAY));
	}
	
	public DrawFactory()
	{
		draws = new LinkedList<Draw>();
	}
	
	public void createDraw(int y, int m, int d,
			int m1, int m2, int m3, int m4, int m5,
			int l1, int l2)
	{
		draws.add(new Draw(y,m,d,m1,m2,m3,m4,m5,l1,l2));
	}
	
	public void createDraws()
	{
		
		//createDraw(2011,3,4,28,41,25,11,27,8,5);
		//createDraw(2011,3,11,17,24,37,19,46,2,7);
		//createDraw(2011,3,18,50,13,26,1,20,7,6);
		//createDraw(2011,3,25,12,21,6,33,27,7,3);
		
				
		//2011,4			
		//createDraw(2011,4,1,17,33,22,21,4,4,8);
		//createDraw(2011,4,8,21,47,23,38,50,6,2);
		//createDraw(2011,4,15,4,41,6,21,39,2,6);
		//createDraw(2011,4,22,22,45,48,11,36,1,4);
		//createDraw(2011,4,29,38,40,25,15,41,1,2);
			
		
		//2011,5			
		createDraw(2011,5,6,28,16,20,22,11,4,9);
		createDraw(2011,5,10,28,3,45,10,15,7,5);
		createDraw(2011,5,13,17,47,11,36,9,2,1);
		createDraw(2011,5,17,37,20,21,45,46,3,2);
		createDraw(2011,5,20,42,25,10,20,14,8,11);
		createDraw(2011,5,24,16,23,24,29,26,2,9);
		createDraw(2011,5,27,28,9,49,25,17,9,8);
		createDraw(2011,5,31,22,9,10,50,1,11,5);
						
		
		
		//2011,6			
		createDraw(2011,6,3,49,40,50,39,4,2,5);
		createDraw(2011,6,7,25,38,40,6,36,10,4);
		createDraw(2011,6,10,37,20,3,48,19,8,11);
		createDraw(2011,6,14,41,19,48,5,12,8,10);
		createDraw(2011,6,17,11,22,21,16,44,8,3);
		createDraw(2011,6,21,49,50,20,17,35,4,3);
		createDraw(2011,6,24,41,20,5,30,16,11,6);
		createDraw(2011,6,28,16,15,44,30,50,3,2);
				
																		
		//2011,7			
		createDraw(2011,7,1,11,23,31,8,46,9,8);
		createDraw(2011,7,5,28,47,29,11,49,5,1);
		createDraw(2011,7,8,12,13,40,49,23,7,10);
		createDraw(2011,7,12,19,17,42,45,38,9,10);
		createDraw(2011,7,15,26,6,33,39,34,3,4);
		createDraw(2011,7,19,16,3,25,35,26,5,9);
		createDraw(2011,7,22,4,50,15,49,23,2,6);
		createDraw(2011,7,26,5,1,25,48,22,11,3);
		createDraw(2011,7,29,37,38,19,27,12,5,10);	
				
		//2011,8
		createDraw(2011,8,2,8,33,14,24,5,8,3);
		createDraw(2011,8,5,34,32,18,14,13,1,10);
		createDraw(2011,8,9,36,24,34,7,23,11,8);
		createDraw(2011,8,12,7,20,37,10,27,7,4);
		createDraw(2011,8,16,45,18,1,13,17,8,3);
		createDraw(2011,8,19,16,6,31,28,14,11,2);
		createDraw(2011,8,23,42,50,6,14,4,2,4);
		createDraw(2011,8,26,25,45,22,33,12,5,7);
		createDraw(2011,8,30,46,8,2,10,19,5,9);
		
		//2011,9
		createDraw(2011,9,2,37,12,26,38,44,4,7);
		createDraw(2011,9,6,42,35,50,48,47,9,8);
		createDraw(2011,9,9,21,5,34,31,28,2,1);
		createDraw(2011,9,13,28,32,49,9,30,9,10);
		createDraw(2011,9,16,39,2,42,17,8,3,10);
		createDraw(2011,9,20,25,38,19,9,36,11,7);
		createDraw(2011,9,23,6,33,48,14,34,6,2);
		createDraw(2011,9,27,28,18,40,27,35,3,5);
		createDraw(2011,9,30,28,15,44,31,5,1,6);
		
		
		//2011,10
		createDraw(2011,10,4,14,16,23,45,38,8,11);
		createDraw(2011,10,7,42,34,18,38,26,8,5);
		createDraw(2011,10,11,12,16,4,1,48,9,10);
		createDraw(2011,10,14,47,23,12,29,32,3,5);
		createDraw(2011,10,18,46,18,37,48,23,2,10);
		createDraw(2011,10,21,37,19,2,33,46,5,8);
		createDraw(2011,10,25,39,28,22,12,27,4,10);
		createDraw(2011,10,28,39,16,20,17,50,4,8);

		//2011,11
		createDraw(2011,11,1,20,45,23,14,46,1,11);
		createDraw(2011,11,4,41,50,11,43,14,9,2);
		createDraw(2011,11,8,40,15,4,29,1,1,5);
		createDraw(2011,11,11,30,18,1,4,23,3,7);
		createDraw(2011,11,15,47,17,22,6,45,3,11);
		createDraw(2011,11,18,39,44,24,4,12,2,4);
		createDraw(2011,11,22,16,40,38,24,18,2,4);
		createDraw(2011,11,25,34,14,26,19,28,5,8);
		createDraw(2011,11,29,25,50,11,45,41,7,2);
		
		//2011,12
		createDraw(2011,12,2,27,40,7,43,30,9,8);
		createDraw(2011,12,6,34,21,20,38,19,9,3);
		createDraw(2011,12,9,21,12,47,44,29,2,1);
		createDraw(2011,12,13,12,37,18,33,7,1,11);
		createDraw(2011,12,16,10,2,23,31,5,5,2);
		createDraw(2011,12,20,14,48,1,9,12,7,1);
		createDraw(2011,12,23,22,7,24,28,21,1,11);
		createDraw(2011,12,27,26,21,25,19,44,7,3);
		createDraw(2011,12,30,36,44,43,16,50,8,7);
		
		
		
		
		//2012,1
		createDraw(2012,1,3,42,30,45,3,49,5,10); //check
		createDraw(2012,1,6,1,6,10,31,12,7,2); //check
		createDraw(2012,1,10,9,4,30,10,40,9,2); //check
		createDraw(2012,1,13,39,11,21,14,27,8,6); //check
		createDraw(2012,1,17,12,44,22,30,31,5,6); //check
		createDraw(2012,1,20,10,28,27,2,22,8,6); //check
		createDraw(2012,1,24,1,20,6,2,36,11,8); //check
		createDraw(2012,1,27,10,19,44,13,39,6,2); //check
		createDraw(2012,1,31,43,34,38,9,45,4,2); //check
		
		
		//2012,2
		createDraw(2012,2,3,16,20,19,25,28,1,10);
		createDraw(2012,2,7,15,3,17,33,28,2,4);
		createDraw(2012,2,10,3,14,31,41,8,7,11);
		createDraw(2012,2,14,36,14,42,46,27,11,8);
		createDraw(2012,2,17,11,4,47,28,38,11,10);
		createDraw(2012,2,21,11,24,14,25,29,11,7);
		createDraw(2012,2,24,34,3,12,26,7,10,8);
		createDraw(2012,2,28,10,48,1,17,33,2,3);
		
		
		//2012,3
		createDraw(2012,3,2,44,5,11,6,30,6,2);
		createDraw(2012,3,6,23,47,27,37,24,6,2);
		createDraw(2012,3,9,39,36,32,47,3,6,9);
		createDraw(2012,3,13,47,1,25,10,43,8,9);
		createDraw(2012,3,16,12,4,50,3,23,4,7);
		createDraw(2012,3,20,28,30,15,16,46,3,4);
		createDraw(2012,3,23,50,15,9,23,31,8,11);
		createDraw(2012,3,27,29,36,27,34,24,7,8);
		createDraw(2012,3,30,46,17,23,4,36,10,6);
		


		
		//2012.4
		createDraw(2012,4,3,1,8,18,25,30,10,9);
		createDraw(2012,4,6,11,35,45,20,30,2,3);
		createDraw(2012,4,10,37,27,22,25,36,9,5);
		createDraw(2012,4,13,8,39,43,13,26,3,6);
		createDraw(2012,4,17,10,28,49,48,33,10,1);
		createDraw(2012,4,20,32,41,29,3,6,11,10);
		createDraw(2012,4,24,8,24,48,43,9,3,5);
		createDraw(2012,4,27,36,43,30,27,20,1,6);
		
		//2012,5
		createDraw(2012,5,1,4,15,41,5,19,11,9); //check
		createDraw(2012,5,4,26,41,40,39,3,1,2); //check
		createDraw(2012,5,8,3,34,48,38,21,5,8); //check
		createDraw(2012,5,11,1,17,13,44,38,2,11); //check
		createDraw(2012,5,15,13,2,50,11,26,5,2); //check
		createDraw(2012,5,18,29,50,43,47,13,9,11);//check
		createDraw(2012,5,22,31,32,41,16,37,7,1);//check
		createDraw(2012,5,25,35,12,22,49,46,2,8); //check
		createDraw(2012,5,29,28,17,25,15,8,3,11);//check
		

		
		
		/*
		createDraw(2012,5,1,4,5,15,19,41,9,11); //check
		createDraw(2012,5,4,3,26,39,40,41,1,2); //check
		createDraw(2012,5,8,3,21,34,38,48,5,8); //check
		createDraw(2012,5,11,1,13,17,38,44,2,11); //check
		createDraw(2012,5,15,2,11,13,26,50,2,5); //check
		createDraw(2012,5,18,13,29,43,47,50,9,11); //check
		createDraw(2012,5,22,16,31,32,37,41,1,7); //check
		createDraw(2012,5,25,12,22,35,46,49,2,8);//check
		createDraw(2012,5,29,8,15,17,25,28,3,11); //check
		*/
		createDraw(2012,6,1,2,4,14,26,36,9,10); //check
		createDraw(2012,6,5,13,34,37,47,49,8,9); //check
		createDraw(2012,6,8,5,11,22,34,40,9,11); //check
		createDraw(2012,6,12,8,15,26,30,48,9,10); //check
		createDraw(2012,6,15,10,22,27,38,48,3,7); //check
		createDraw(2012,6,19,7,17,20,35,50,5,11); //check
		createDraw(2012,6,22,14,18,19,43,49,3,7); //check
		createDraw(2012,6,26,1,11,20,22,35,8,10); //check
		createDraw(2012,6,29,14,17,28,29,39,1,11); //check
		
		createDraw(2012,7,3,2,7,22,27,40,3,6); //check
		createDraw(2012,7,6,31,32,38,40,42,1,3); //check
		createDraw(2012,7,10,1,3,16,24,37,1,8); //check
		createDraw(2012,7,13,8,18,25,35,46,4,9); //check
		createDraw(2012,7,17,2,7,24,43,46,8,10); //check
		createDraw(2012,7,20,10,19,23,45,49,9,10); //check
		createDraw(2012,7,24,4,16,18,25,44,1,11); //check
		createDraw(2012,7,27,14,15,21,23,48,2,10);//check
		createDraw(2012,7,31,4,29,35,36,39,8,9); //check
		
		createDraw(2012,8,3,24,34,35,42,46,1,5); //check
		createDraw(2012,8,7,20,27,34,46,50,2,3); //check
		createDraw(2012,8,10,11,17,21,48,50,9,10);
		createDraw(2012,8,14,1,16,38,42,45,9,10);
		createDraw(2012,8,17,19,25,28,33,44,2,8);
		createDraw(2012,8,21,4,5,17,38,48,3,4);
		createDraw(2012,8,24,5,6,12,19,37,3,7);
		createDraw(2012,8,28,1,18,25,26,44,4,5);
		createDraw(2012,8,31,16,28,31,33,48,7,11);
		
		createDraw(2012,9,4,11,17,18,39,44,5,10);
		createDraw(2012,9,7,13,15,30,35,42,4,6);
		createDraw(2012,9,11,6,15,22,37,44,2,4);
		createDraw(2012,9,14,3,10,23,27,44,7,9);
		createDraw(2012,9,18,6,7,38,39,44,7,9);
		createDraw(2012,9,21,4,19,34,41,43,7,11);
		createDraw(2012,9,25,7,25,27,48,49,1,4);
		createDraw(2012,9,28,20,23,26,30,33,6,9);
		
		createDraw(2012,10,2,4,16,21,36,42,7,8);
		createDraw(2012,10,5,9,16,18,19,21,2,3);
		createDraw(2012,10,9,2,8,10,23,25,8,9);
		createDraw(2012,10,12,6,7,17,35,43,2,8);
		createDraw(2012,10,16,10,32,40,41,49,2,8);
		createDraw(2012,10,19,16,29,37,40,44,8,10);
		createDraw(2012,10,23,1,28,35,38,50,2,10);
		createDraw(2012,10,26,5,6,9,27,38,5,11);
		createDraw(2012,10,30,23,24,25,31,44,2,3);
		
		createDraw(2012,11,2,3,6,10,11,44,3,4);
		createDraw(2012,11,6,7,20,25,35,41,1,9);
		createDraw(2012,11,9,14,21,22,28,47,4,5);
		createDraw(2012,11,13,11,16,21,24,29,2,6);
		createDraw(2012,11,16,10,15,19,23,41,2,9);
		createDraw(2012,11,20,28,30,42,45,49,5,10);
		createDraw(2012,11,23,1,9,11,20,40,1,5);
		createDraw(2012,11,27,6,10,23,44,49,1,7);
		createDraw(2012,11,30,10,18,23,24,40,3,4);

		createDraw(2012,12,4,5,10,28,29,44,2,4);
		createDraw(2012,12,7,10,16,18,31,42,2,5);
		createDraw(2012,12,11,1,4,9,43,50,6,8);
		createDraw(2012,12,14,10,11,29,40,43,3,11);
		createDraw(2012,12,18,14,18,20,35,44,2,5);
		createDraw(2012,12,21,3,5,22,40,42,3,10);
		createDraw(2012,12,25,14,18,20,23,32,3,10);
		createDraw(2012,12,28,17,24,26,27,49,3,5);
		
		createDraw(2013,1,1,2,7,8,36,49,1,11);
		createDraw(2013,1,4,4,10,22,27,41,8,10);
		createDraw(2013,1,8,2,20,22,26,47,5,9);
		createDraw(2013,1,11,4,22,29,37,41,4,7);
		createDraw(2013,1,15,22,38,40,42,47,1,11);
		createDraw(2013,1,18,4,26,27,30,39,3,10);
		createDraw(2013,1,22,1,10,44,45,48,1,4);
		createDraw(2013,1,25,3,10,18,31,37,2,4);
		createDraw(2013,1,29,9,16,26,36,39,2,6);
		
		createDraw(2013,2,1,5,21,34,37,38,1,6);
		createDraw(2013,2,5,6,25,31,40,45,6,7);
		createDraw(2013,2,8,9,11,14,34,44,10,11);
		createDraw(2013,2,12,5,11,16,25,28,7,9);
		createDraw(2013,2,15,2,4,22,28,42,4,9);
		createDraw(2013,2,19,12,15,28,30,44,8,9);
		createDraw(2013,2,22,15,16,28,36,37,2,11);
		createDraw(2013,2,26,3,12,13,17,30,2,6);
		
		createDraw(2013,3,1,1,11,29,36,42,4,5);
		createDraw(2013,3,5,8,19,31,33,39,2,7);
		createDraw(2013,3,8,3,20,23,27,42,8,11);
	}
	
	public LinkedList<Draw> getDraws()
	{
		return draws;
	}
	
	public String createFileString(int day)
	{
		String result = "";
		result += "Date,";
		for(int i = 1; i <= 50; i++)
		{
			result += i+",";
		}
		for(int i = 1; i <= 11; i++)
		{
			result += i+",";
		}
		result += "\n";
		
		for(Draw draw: draws)
		{
			if(draw.getDate().get(Calendar.DAY_OF_WEEK) == day)
			{
				result += draw.getDateString() + ",";
				for(int i = 1; i <= 50; i++)
				{
					if (numberExistInMain(i, draw.getMains())) {
						result += "*,";
					}
					else {
						result += ",";
					}
				}
				
				for(int i = 1; i <= 11; i++)
				{
					if(numberExistInLucky(i, draw.getLuckys()))
					{
						result += "*,";
					}
					else {
						result += ",";
					}
				}
				result += "\n";
			}
		}
		
		return result;
	}
	
	public boolean numberExistInMain(int num, LinkedList<MainBall> list)
	{
		boolean result = false;
		for(Ball ball: list)
		{
			if (ball.getName() == num) {
				result = true;
				break;
			}
		}
		return result;
	}
	
	public boolean numberExistInLucky(int num, LinkedList<LuckyBall> list)
	{
		boolean result = false;
		for(Ball ball: list)
		{
			if (ball.getName() == num) {
				result = true;
				break;
			}
		}
		return result;
	}
}
